<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 16-10-19
 * Time: 上午10:01
 */

namespace Home\Model;


use Think\Model;

class loginlogModel extends Model {

    public $loginlog;
    protected $tableName = 'user_loginlog';
    /**
     * 公共构造方法
     */
    public function __construct()
    {
        parent::__construct();
        $this->loginlog = M("user_loginlog");
    }

    /**
     * function insert
     * @param $data
     * @return bool
     */
    public function InsertLoginLog($data)
    {
        if(!count($data))
        {
            return false;
        }

        $res = $this->loginlog->data($data)->add();
        return $res;

    }

    /**
     * 更新用户登录日志
     * @author mmy
     * @param $logId
     */
    public function updateLog($logId)
    {
        if(empty($logId))
        {
            return false;
        }

        $sql = "id=".$logId;
        $this->loginlog->outtime = date('Y-m-d H:i:s',time());
        $res = $this->loginlog->where($sql)->save();
        return $res;
    }

} 